package com.flyco.modules.pms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.flyco.modules.pms.entity.StmJdWmsStock;
import com.flyco.modules.pms.mapper.StmJdWmsStockMapper;
import com.flyco.modules.pms.service.IStmJdWmsStockService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * @Description: 旺店通产品库存表
 * @Author: flyco
 * @Date: 2023-08-17
 * @Version: V1.0
 */
@Service
public class StmJdWmsStockServiceImpl extends ServiceImpl<StmJdWmsStockMapper, StmJdWmsStock> implements IStmJdWmsStockService {


    @Override
    public StmJdWmsStock getBySkuCode(String skuCode) {
        LambdaQueryWrapper<StmJdWmsStock> wrapper = new LambdaQueryWrapper<>();
        //wrapper.eq(StmJdWmsStock::getSkuCode, skuCode).eq(StmJdWmsStock::getWareHouseNo, "1001");
        wrapper.eq(StmJdWmsStock::getSkuCode, skuCode);
        List<StmJdWmsStock> stockList = list(wrapper);
        if (CollectionUtils.isEmpty(stockList)) {
            return null;
        }
        return stockList.get(0);
    }

    @Override
    public List<StmJdWmsStock> getBySkuCodeList(List<String> skuCodeList, Long partnerId) {
        LambdaQueryWrapper<StmJdWmsStock> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(StmJdWmsStock::getSkuCode, skuCodeList).eq(StmJdWmsStock::getPartnerId, partnerId);
        List<StmJdWmsStock> stockList = list(wrapper);
        return stockList;
    }
}
